TCGA BRCA
Import TPM data
ssGSEA
ssGSEA by HALLMARK
library(clusterProfiler)
hallmark <- msigdbr::msigdbr(species = "Homo sapiens", category = "H") %>%
dplyr::select(gs_name, gene_symbol)
gs_names = hallmark$gs_name %>% unique()
hallmakrList = list()
# 리스트 초기화
hallmarkList <- list()
# 반복문을 사용하여 각 고유 gs_name에 대해 필터링 및 리스트 생성
for (i in seq_along(gs_names)) {
hallmarkList[[gs_names[i]]] <- hallmark %>%
filter(gs_name == gs_names[i]) %>%
dplyr::select(gene_symbol) %>%
pull()
}## Perform ssgsea
library(corto)
## Input data : tpm (count.mtx is accepted as well)
test = ssgsea(tpms,hallmarkList)
## Reshape it to plot
test.df = test %>% t() %>% data.frame()
rownames(test.df) = colnames(tpms)
## p value of ssgsea
pval = corto::z2p(test)
colnames(pval) = rownames(test.df)# meta = colData(dds)
meta = TCGA_BRCA_tpmsMeta$meta
anno.col = meta[,"sample_type"] %>% as.data.frame()
rownames(anno.col) = rownames(meta)
colnames(anno.col) = "sample"
anno.col = anno.col %>% arrange(sample)
## Heatmap
my.color=c(colorRampPalette(colors = c("#2874A6","white"))(70),
colorRampPalette(colors = c("white","#D35400"))(70))
t(test.df[rownames(anno.col),]) %>% pheatmap::pheatmap(color = my.color,
cluster_rows = T,
cluster_cols = F,
main = "ssGSEA of HALLMARK pathways",
show_rownames = T,
show_colnames = F,
annotation_col = anno.col,
fontsize_row = 7) # Simple heatmap ssGSEA by HALLMARK version 2
## Heatmap
my.color=c(colorRampPalette(colors = c("#2874A6","white"))(70),
colorRampPalette(colors = c("white","#D35400"))(70))
t(test.df[rownames(anno.col),]) %>% pheatmap::pheatmap(color = my.color,
cluster_rows = T,
cluster_cols = T,
main = "ssGSEA of HALLMARK pathways",
show_rownames = T,
show_colnames = F,
annotation_col = anno.col,
fontsize_row = 5) # Simple heatmap ssGSEA by KEGG
kegg <- msigdbr::msigdbr(species = "Homo sapiens", subcategory = "CP:KEGG") %>%
dplyr::select(gs_name, gene_symbol)
gs_names = kegg$gs_name %>% unique()
geneList = list()
# 리스트 초기화
geneList <- list()
# 반복문을 사용하여 각 고유 gs_name에 대해 필터링 및 리스트 생성
for (i in seq_along(gs_names)) {
geneList[[gs_names[i]]] <- kegg %>%
filter(gs_name == gs_names[i]) %>%
dplyr::select(gene_symbol) %>%
pull()
}## Perform ssgsea
library(corto)
## Input data : tpm (count.mtx is accepted as well)
test = ssgsea(tpms,geneList)
## Reshape it to plot
test.df = test %>% t() %>% data.frame()
rownames(test.df) = colnames(tpms)
## p value of ssgsea
pval = corto::z2p(test)
colnames(pval) = rownames(test.df)## Heatmap
my.color=c(colorRampPalette(colors = c("#2874A6","white"))(70),
colorRampPalette(colors = c("white","#D35400"))(70))
t(test.df[rownames(anno.col),]) %>% pheatmap::pheatmap(color = my.color,
cluster_rows = T,
cluster_cols = F,
main = "ssGSEA of KEGG pathways",
show_rownames = T,
show_colnames = F,
annotation_col = anno.col,
fontsize_row = 5) # Simple heatmap ssGSEA by KEGG version 2
## Heatmap
my.color=c(colorRampPalette(colors = c("#2874A6","white"))(70),
colorRampPalette(colors = c("white","#D35400"))(70))
t(test.df[rownames(anno.col),]) %>% pheatmap::pheatmap(color = my.color,
cluster_rows = T,
cluster_cols = T,
main = "ssGSEA of KEGG pathways",
show_rownames = T,
show_colnames = F,
annotation_col = anno.col,
fontsize_row = 5) # Simple heatmap